/***
 *
 * play sound trigger
 */

var CONSTRUCT3 = {}
CONSTRUCT3.Instancekey = "JumpSoundTriger"

CONSTRUCT3.HanderCount = 0


var CONSTRUCT3_ACTION = {}
var CONSTRUCT3_NODE_INSTANCE = {}
var CONSTRUCT3_VARABLE = {}

var CONSTRUCT3_ENUM = {}
var CONSTRUCT3_FUNC = {}



c3.c3_Initfram(CONSTRUCT3.InstanceKey, () => {

    var PlaySoundTriggerInstanClass = c3.EVENT_GET_INSTANCE_CLASS(CONSTRUCT3.n.InstanceKey)
    for (let alls of PlaySoundTriggerInstanClass) {
        alls.isVisible = false
    }
})


c3.c3_Initfram(CONSTRUCT3.Instancekey, function Playerentertrigger() {

    CONSTRUCT3_ACTION.PlayerInTrigger = "pl_in_sound_triger"

    c3.ClientConstruct3EventActionHander(CONSTRUCT3_ACTION.PlayerInTrigger, (e) => {
        CONSTRUCT3.HanderCount += 1
        var st_instance = e.detail[0]

        var playSoundTrigger = {}

        playSoundTrigger.Name = c3.getIsntanceInstVar(st_instance, "soundName")
        playSoundTrigger.Looptype = c3.getIsntanceInstVar(st_instance, "type")
        playSoundTrigger.OnlyOnce = c3.getIsntanceInstVar(st_instance, "only")
        playSoundTrigger.ListeningTimes = c3.getIsntanceInstVar(st_instance, "playetimes")


        if (playSoundTrigger.Name == "") return
        if (playSoundTrigger.OnlyOnce) {
            if (playSoundTrigger.ListeningTimes >= 1) {
                return
            }
        }

        switch (playSoundTrigger.Looptype) {
            case 0:
                CONSTRUCT3.func_playSoundByObject(playSoundTrigger.Name, st_instance.uid)
                break
            case 1:
                CONSTRUCT3.func_playSoundByObjectLoop(playSoundTrigger.Name, st_instance.uid)
                break
            case 2:
                break
        }

    }, CONSTRUCT3.HanderCount)
})

CONSTRUCT3.func_playSound = function PlaySound(name) {
    c3.e_Invoke("playeSound", name)
}
CONSTRUCT3.func_playSoundLoop = function PlaySoundLoop(name) {
    c3.e_Invoke("playeSoundLoop", name)
}
CONSTRUCT3.func_playSoundByObject = function PlaySoundByObject(name, uid) {
    c3.e_Invoke("playeSoundbyobject", name, uid)
}
CONSTRUCT3.func_playSoundByObjectLoop = function PlaySoundByObjectLoop(name, uid) {
    c3.e_Invoke("playeSoundbyobjectloop", name, uid)
}

